#include "s_glcd.h"
#include "uart.h"

/*
 * lcd.c
 *
 *  Created on: Jun 15, 2011
 *      Author: ben
 */

void onMainMenu()
{
	onClearScreen();
	onSetX(0x25);
	USARTWriteString("Main Menu");

	onSetX(0x00);
	onSetY(Y_MIDDLE + 2*CHAR_HEIGHT);
	USARTWriteString("GPS");

	onSetX(0x00);
	onSetY(Y_MIDDLE - 2*CHAR_HEIGHT);
	USARTWriteString("Temp");

	onSetX(X_MAX - 3*CHAR_LENGTH);
	onSetY(Y_MIDDLE + 2*CHAR_HEIGHT);
	USARTWriteString("Car");

	onSetX(X_MAX - 3*CHAR_LENGTH);
	onSetY(Y_MIDDLE - 2*CHAR_HEIGHT);
	USARTWriteString("Amp");
}

void onGPSMenu()
{
	onClearScreen();
	onSetX(X_MIDDLE - 1.5*CHAR_LENGTH);
	USARTWriteString("GPS");
}

void onClearScreen()
{
	USARTWriteChar(CTL);
	USARTWriteChar(CLR);
}

void onSetX(char x_spot)
{
	USARTWriteChar(CTL);
	USARTWriteChar(SET_X);
	USARTWriteChar(x_spot);
}

void onSetY(char y_spot)
{
	USARTWriteChar(CTL);
	USARTWriteChar(SET_Y);
	USARTWriteChar(y_spot);
}

void onSetXY(char x_spot, char y_spot)
{
	onSetX(x_spot);
	onSetY(y_spot);
}

void onDrawLine(char x1, char y1, char x2, char y2)
{
	USARTWriteChar(CTL);
	USARTWriteChar(DRAW_LINE);
	USARTWriteChar(x1);
	USARTWriteChar(y1);
	USARTWriteChar(x2);
	USARTWriteChar(y2);

}

void onDrawBox(char x1, char y1, char x2, char y2)
{
	USARTWriteChar(CTL);
	USARTWriteChar(DRAW_BOX);
	USARTWriteChar(x1);
	USARTWriteChar(y1);
	USARTWriteChar(x2);
	USARTWriteChar(y2);
}
